<template>
	<view class="my-account">
		<!--标题栏-->
		<bar-title bgColor='bg-white'>
			<block slot="content">我的账户</block>
		</bar-title> 
		
		<view class="balance-warp">
			<view class="title">
				<view class="left">现金余额</view>
				<view class="right" @click="goPages('widthdraw')">去提现 
					<text class="cuIcon-right"></text>
				</view>
			</view>
			<view class="balance">
				<image class="icon" src="/static/img/ic_mine_account_rmb.png" mode="aspectFill"></image>
				<view class="num">{{balanceaccount}}</view>
			</view>
		</view>  
		<view class="balance-warp">
			<view class="title">
				<view class="left">钻石余额</view>
				<!-- <view class="right">去充值 <text class="cuIcon-right"></text></view> -->
			</view>
			<view class="balance">
				<image class="icon" src="/static/img/ic_mine_account_diamond.png" mode="aspectFill"></image>
				<view class="num">{{diamond}}</view>
			</view>
		</view>
		
		<view class="balance-warp">
			<view class="title">
				<view class="left">米豆余额</view>
				<!-- <view class="right">去兑换 <text class="cuIcon-right"></text></view> -->
			</view>
			<view class="balance">
				<image class="icon" src="/static/img/ic_mine_account_bean.png" mode="aspectFill"></image>
				<view class="num">{{bean}}</view>
			</view>
		</view>
		
		<view class="cu-form-group " @click="goPages('bankDetail')">
			<view class="title">
				<image class="icon" src="/static/img/ic_mine_account_mx.png" mode="aspectFill"></image>
				<text class="margin-left-sm">收支明细</text>
			</view>
			<view class="action">
				<text class="cuIcon-right"></text>
			</view>
		</view>
		
		<view class="cu-form-group" @click="goPages('bankManage')">
			<view class="title">
				<image class="icon" src="/static/img/ic_mine_account_bank.png" mode="aspectFill"></image>
				<text class="margin-left-sm">提现账户管理</text>
			</view>
			<view class="action">
				<text class="cuIcon-right"></text>
			</view>
		</view>
		
	</view>
</template>

<script>
import { mapState } from 'vuex';
import { User } from '@/models/user.js';
let user = new User()
export default {
	onShow() {
		this.getAccountBalance();
		this.getFaultAccount();
	},
	data() {
		return {
			balanceaccount: 0,
			diamond: 0,
			bean: 0,
			bank: false
		}
	},
	methods:{
		goPages(pageName) {
			if(pageName=='widthdraw' && this.noBank) {
				this.$jumpPages('bankModify')
				return
			}
			this.$jumpPages(pageName)
		},
		
		async getAccountBalance(data) {
			await user.getUserAccount()
			this.balanceaccount = user.balanceaccount
			this.diamond = user.diamond
			this.bean = user.bean
		},
		async getFaultAccount() {
			let bankInfo = await user.getFaultAccount(true);
			this.noBank = bankInfo.alipayaccount == ""
		},
	}
}
</script>

<style lang="scss" scoped>
	.balance-warp{
		border-radius: 20rpx 20rpx 0 0;
		margin: 20rpx 30rpx;
		background-color: #FFFFFF;
		padding: 40rpx 50rpx 50rpx 40rpx;
		.title{
			color: #323232;
			font-size: 30rpx;
			display: flex;
			justify-content: space-between;
		}
		.balance{
			margin-top: 60rpx;
			display: flex;
			align-items: baseline;
		}
		.icon{
			width: 26rpx;
			height: 26rpx;
			margin-right: 10rpx;
		}
		.num{
			font-size: 52rpx;
			line-height: 1;
		}
	}
	.cu-form-group{
		.title{
			display: flex;
			align-items: center;
		}
		.icon{
			width: 32rpx;
			height: 32rpx;
		}
	}
</style>
